"""
Tensor的运算
- 加减乘除
- 矩阵运算
- 幂运算
- 对数运算
"""
import torch

# 加法
# a = torch.rand(2, 3)
# b = torch.rand(2, 3)
# print(a)
# print(b)
# print("------------------------------")
# print(a + b)
# print(a.add(b))
# print(torch.add(a, b))
# print(a.add_(b))
# print(a)

# 减法
# print(a - b)
# print(torch.sub(a, b))
# print(a.sub(b))
# print(a.sub_(b))
# print(a)

# 乘法
# print(a * b)
# print(torch.mul(a, b))
# print(a.mul(b))
# print(a.mul_(b))
# print(a)

# 除法
# print(a/b)
# print(torch.div(a, b))
# print(a.div(b))
# print(a.div_(b))
# print(a)

# 矩阵
# a = torch.ones(2, 1)
# b = torch.ones(1, 2)
# print(a)
# print(b)
# print("---------------------")
# print(a @ b)
# print(a.matmul(b))
# print(torch.matmul(a, b))
# print(torch.mm(a, b))
# print(a.mm(b))

# 高维tensor
# a = torch.ones(1, 2, 3, 4)
# b = torch.ones(1, 2, 4, 3)
# print(torch.matmul(a, b))

# 指数运算
# a = torch.tensor([1, 2])
# print(torch.pow(a, 3))
# print(a.pow(3))
# print(a ** 3)
# print(a.pow_(3))

# 自然常数e
a = torch.tensor([10, 2], dtype=torch.float32)
# print(torch.exp(a))
# print(torch.exp_(a))
# print(a.exp())
# print(a.exp_())

# print(torch.log(a))
# print(torch.log_(a))
# print(a.log())
# print(a.log_())

# 开平方
# print(torch.sqrt(a))
# print(a.sqrt())
# print(torch.sqrt_(a))
# print(a.sqrt_())



